<template>
  <div>
    <van-nav-bar
      :title="title"
      left-text="返回"
      left-arrow
      @click-left="goBlack"
      @click-right="onClickRight"
      class="an-nav"
    >
      <template v-if="$slots.NavLeft" #left>
        <slot name="NavLeft"></slot>
      </template>
      <template v-if="$slots.NavRight" #right>
        <slot name="NavRight"></slot>
      </template>
    </van-nav-bar>
    <slot></slot>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: "标题",
    },
  },
  mounted() {
    document.title = this.title;
  },
  methods: {
    goBlack() {
      this.$router.go(-1);
    },

    onClickRight() {
      this.$emit("onClickRight");
    },
  },
};
</script>
